package com.github.thinwonton.springboot.showcase.web.exception.handle.domain;

public class RestResult<T> {
    public static final Integer OK = 0;
    public static final Integer ERROR = -1;
    private Integer code;
    private String message;
    private String url;
    private T data;

    public static <T>RestResult<T> error(String message) {
        RestResult<T> object = new RestResult<>();
        object.setCode(ERROR);
        object.setMessage(message);
        return object;
    }

    public static <T>RestResult<T> error(String message, String url) {
        RestResult<T> object = new RestResult<>();
        object.setCode(ERROR);
        object.setMessage(message);
        object.setUrl(url);
        return object;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
